<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>



<script type="text/javascript">
	function writeForm() {
		//추후 로그인 세션 처리 해야함(설정에 따라 로그인한 사람만 글쓰기 제한이 걸리도록)
		var menu = window.document.menu;
		menu.method="post";
		menu.action = "/${initParam.context_root }/board/writeForm.do";
		//return false;
	}
</script>
	

<table align="center" class="table table-bordered" id="content"  id="list" style="width: 1000px;">
	<tr  class="danger" align="center" >
		<td width="65px" align="center">글번호</td>
		<td align="center">제목</td>
		<td width="100px" align="center">작성자</td>
		<td width="100px" align="center">작성일</td>
		<td width="60px" align="center">조회수</td>
	</tr>
	<c:forEach items="${requestScope.list }" var="board">
		<tr>
			<td>${board.paperNum }</td>
			<td>
				<c:forEach begin="1" end="${board.relevel }" step="1">
					&nbsp;&nbsp;
				</c:forEach>
				<c:if test="${board.relevel != 0 }">
					→
				</c:if>
				<a href="/${initParam.context_root }/board/getContent.do?bid=${requestScope.boardId}&num=${board.paperNum }&page=${requestScope.pagingBean.currentPage}">
					${board.title }
				</a>
			</td>
			<td>${board.writer }</td>
			<td>${board.writeDate }</td>
			<td align="right">${board.cnt }</td>
		</tr>	
	</c:forEach>
	
</table>
<p>
<table align="center">
	<tr>
		<td>		
		<c:choose>
			<c:when test="${requestScope.pagingBean.previousPageGroup }">
				<a href="/${initParam.context_root }/board/list.do?bid=${requestScope.boardId}&page=${requestScope.pagingBean.startPageOfPageGroup -1 }">
				◀
				</a>
			</c:when>
			<c:otherwise>
				◀
			</c:otherwise>
		</c:choose>
		<c:forEach begin="${requestScope.pagingBean.startPageOfPageGroup }"
							   end="${requestScope.pagingBean.endPageOfPageGroup }"
							   step="1"
							   var ="i">
			<c:choose>
				<c:when test="${i == requestScope.pagingBean.currentPage }">
					${i }
				</c:when>
				<c:otherwise>
					<a href="/${initParam.context_root }/board/list.do?bid=${requestScope.boardId}&page=${i }">${i }</a>
				</c:otherwise>
			</c:choose>			
		</c:forEach>
		<c:choose>
			<c:when test="${requestScope.pagingBean.nextPageGroup }">
				<a href="/${initParam.context_root }/board/list.do?bid=${requestScope.boardId}&page=${requestScope.pagingBean.endPageOfPageGroup + 1 }">
					▶
				</a>
			</c:when>
			<c:otherwise>
				▶
			</c:otherwise>
		</c:choose>
		
		<td>
	</tr>
</table>

<form name='menu' onsubmit='return writeForm()'>
	<input type="hidden" name="bid" value="${requestScope.boardId}"/>
	<p class="text-center"><button type="submit" class="btn btn-default">등록하기</button></p>

</form>